import React from 'react';
import ReactDOM from 'react-dom';
import mirror, {actions, connect} from 'mirrorx';
import { ActionSheet, WingBlank, WhiteSpace, Button, Toast, List,Modal } from 'antd-mobile';
const Item = List.Item;


class App extends React.Component { 
	constructor(props) {
		super(props);
        this.state = {
           data:[]
        }
	}

	componentDidMount(){
        this.policyId = T.urlQuery('id');
        this.requestVoice();
    }

    requestVoice = ()=>{
        T.fetch({
            url:'/msg/account/invoicelist/' + this.policyId + '.json',
            method:"get"
        }).then((res)=>{
            if(res.success){              
                let result = res.value || [];
                this.setState({data:result})  
            }
        })
    }

	render() {
		return (
            <div className="mt30 invoice-list">
                <div className="tac strong mb30">Incoice List</div>
                {this.state.data.map((item,index)=>{
                    let result = item.url.match(/^https?\:\/\/([\w\-\.]+)(\/.+)/)||[];
                    let newUrl = result[2] ||"";
                    newUrl = "/translateHost" + newUrl;
                    return <div key={index} className="pt10 pb10 pl15 pr15 bor-bottom clearfix">
                            <a target="_blank" href={newUrl} className="fl">{item.invoiceNo}</a>
                            <span className="fr">{item.amount}</span>
                        </div>
                })}
            </div>
        )
	}
}

export default App;   